#ifndef BEZIERCUBSURF_H_
#define BEZIERCUBSURF_H_

#include <GL/glew.h>
#include <GL/glut.h>
#include <glm/glm.hpp>

#include <string.h>
#include <vector>

#define DETAILBEZIERSURF 5
#define TAMBEZIERSURF 51
#define TAMPATCHBEZIER 4

using std::vector;

class BezierCubSurf{
	public:
		BezierCubSurf();
		BezierCubSurf(GLfloat ctrlpoints[TAMPATCHBEZIER][TAMPATCHBEZIER][3]);
		void drawSurface(glm::mat4 mat);
		void drawControlPoints();
		void drawNormals(glm::mat4);

	private:
		GLfloat controlPoints[TAMPATCHBEZIER][TAMPATCHBEZIER][3];
		float surface[TAMBEZIERSURF][TAMBEZIERSURF][3];
		float normals[TAMBEZIERSURF][TAMBEZIERSURF][3];

		void calculateSurface();
		void calculateNormals();
		void calculateNormalForMiddlePoint(size_t x,size_t y,float h);
		void calculateNormalForPositBorderPoint(size_t x,size_t y,float h);
		void calculateNormalForNegBorderPoint(size_t x,size_t y,float h);
		float baseBezier(size_t n,size_t j,float t);
		long Combinatoria(long a,long b);
		long factorial(long n);
		float pow(float base,size_t exp);

};

#endif
